function opacityForUrl(url) {
    if (!url) {
        return 0;
    } else {
        return 1;
    }
}

function titleWidth(accessoryImageUrl) {
        if (accessoryImageUrl) {
            return column.width - 150;
        } else {
            return column.width - 70;
        }
    }

function imageIcon(type) {
        switch(type) {
        case "User": return "../Images/macapp_icon_following.png";
        case "Media": return "../Images/macapp_icon_photo.png";
        case "Book": return "../Images/macapp_icon_collection.png";
        case "CheckIn": return "../Images/macapp_icon_following.png";
        case "Multiple": return "../Images/macapp_icon_spot.png";
        default: return "../Images/macapp_icon_spot.png";
        }
    }

function whenFromNow(when) {
    when = when.replace(/\D/g," ");
    var comps = when.split(" ");
    comps[1]--;
    var d = new Date(Date.UTC(comps[0],comps[1],comps[2],comps[3],comps[4],comps[5]));
    var now = new Date();
    var delta = now.getHours() - d.getHours();
    if (delta >= 24) { return (delta / 24) + " days ago"; }
    else if (delta > 0) { return delta + " hours ago"; }
    else if (delta < 0) { delta = 24 + delta;
        if (delta) {
            return delta + " hours ago";
        } else {
            delta = 60 + now.getMinutes() - d.getMinutes();
            if (delta) {
                return delta + " minutes ago";
            } else {
                return "less than a minute ago";
            }
        }

    } else {
        delta = now.getMinutes() - d.getMinutes();
        if (delta) {
            return delta + " minutes ago";
        } else {
            return "less than a minute ago";
        }
    }
}
